package com.smarttest.base

import android.arch.lifecycle.Lifecycle
import android.arch.lifecycle.LifecycleObserver
import android.arch.lifecycle.OnLifecycleEvent
import android.content.Context
import com.smarttest.receiver.WifiReceiver
import io.reactivex.disposables.CompositeDisposable
import org.jetbrains.anko.AnkoLogger

/**
 * 说明：
 * Created by code_nil on 2018/1/31.
 * 君子自强不息
 */
class ActivityLifecycleObserver(private val context: Context, private val wifiReceiver: WifiReceiver) : LifecycleObserver, AnkoLogger {
    val disposables = CompositeDisposable()
    @OnLifecycleEvent(Lifecycle.Event.ON_CREATE)
    fun onCreate() {
        WifiReceiver.register(context, wifiReceiver)
    }

    @OnLifecycleEvent(Lifecycle.Event.ON_RESUME)
    fun onResume() {
    }

    @OnLifecycleEvent(Lifecycle.Event.ON_START)
    fun onStart() {
    }

    @OnLifecycleEvent(Lifecycle.Event.ON_PAUSE)
    fun onPause() {

    }

    @OnLifecycleEvent(Lifecycle.Event.ON_STOP)
    fun onStop() {

    }

    @OnLifecycleEvent(Lifecycle.Event.ON_DESTROY)
    fun onDestroy() {
        disposables.clear()
        WifiReceiver.unRegister(context, wifiReceiver)
    }

}